

package swing;

import html.HtmlTreeModel;
import html.HtmlTreeNode;

import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;


public class HtmlTree extends JTree {
 
    public HtmlTree(DefaultMutableTreeNode root) {       
    	super(new HtmlTreeModel(root));
        getSelectionModel().setSelectionMode(
                TreeSelectionModel.SINGLE_TREE_SELECTION);
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        Icon personIcon = null;
        renderer.setLeafIcon(personIcon);
        renderer.setClosedIcon(personIcon);
        renderer.setOpenIcon(personIcon);
        setCellRenderer(renderer);
    }
    public HtmlTree(TreeModel model) {       
    	super(model);
        getSelectionModel().setSelectionMode(
                TreeSelectionModel.SINGLE_TREE_SELECTION);
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        Icon personIcon = null;
        renderer.setLeafIcon(personIcon);
        renderer.setClosedIcon(personIcon);
        renderer.setOpenIcon(personIcon);
        setCellRenderer(renderer);
    }
    /**
     * Get the selected item in the tree, and call showAncestor with this
     * item on the model.
     */
  /*  public void showAncestor(boolean b) {
        Object newRoot = null;
        TreePath path = getSelectionModel().getSelectionPath();
        if (path != null) {
            newRoot = path.getLastPathComponent();
        }
        ((HtmlTreeModel)getModel()).showAncestor(b, newRoot);
    }*/

    public void  setRoot(DefaultMutableTreeNode node)
    {
    	((HtmlTreeModel)getModel()).setRoot(node);
    }
    
}